//
//  GGZFBFriendsCell.m
//  Gunterapple
//
//  Created by 热带雨林 on 2020/4/2.
//  Copyright © 2020 热带雨林. All rights reserved.
//

#import "GGZFBFriendsCell.h"
#import "GGAddtion.h"
#import "ZFBFriendModel.h"
@interface GGZFBFriendsCell ()
@property (nonatomic, weak)UIImageView *icon;
@property (nonatomic, weak)UILabel *name;
@property (nonatomic, weak)UILabel *time;
@property (nonatomic, weak)UILabel *subTitle;

@end
@implementation GGZFBFriendsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setUpUI];
    }
    return self;
}
- (void)setUpUI{
    UIImageView *icon = [[UIImageView alloc]initWithFrame:CGRectZero];
    self.icon = icon;
    [self.contentView addSubview:icon];
    
    UILabel *name = [[UILabel alloc]init];
    self.name = name;
    self.name.font = [UIFont systemFontOfSize:15];
    [self.name sizeToFit];
    [self.contentView addSubview:name];
    
    UILabel *time = [[UILabel alloc]init];
    self.time = time;
    time.font = [UIFont systemFontOfSize:9];
    [time sizeToFit];
    [self.contentView addSubview:time];
    
    UILabel *sublabel = [[UILabel alloc]init];
    self.subTitle = sublabel;
    self.subTitle.font = [UIFont systemFontOfSize:13];
    [self.subTitle sizeToFit];
    [self.contentView addSubview:self.subTitle];
    
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(25);
        make.left.equalTo(self.contentView).offset(25);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.icon.mas_right).offset(10);
        make.top.equalTo(self.icon);
    }];
    [self.time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
    }];
    [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.name);
        make.bottom.equalTo(self.icon.mas_bottom);
        make.width.lessThanOrEqualTo(@300);
    }];
}
- (void)setModel:(ZFBFriendModel *)model{
    _model = model;
    self.icon.image = [UIImage imageNamed:model.icon];
    self.name.text = model.title;
    self.time.text = model.time;
    self.subTitle.text = model.subTitle;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
